#include "stdio.h"

#define CHR_H 16 // character height

int main()
{
	unsigned char table[256*CHR_H]; FILE *fp; int i, j, k=0;
	fp = fopen("po.dat", "rb"); //error check removed for brevety
	fread(table, 256*CHR_H, 1, fp);
	fclose(fp);

	FILE* fp_out = fopen("codepage.c", "w");
	if(fp_out)
	{
		fprintf(fp_out,"static char local_table[] = {\n");
		for(i=0; i<256; i++) {
		  for(j=0; j<CHR_H; j++)
			 fprintf(fp_out,"0x%02x, ", table[k++]);
		  fprintf(fp_out,"/* character 0x%02x */\n", i);
		}
		fprintf(fp_out,"};\n\n"
			  "#include \"string.h\"\n"
			  "void load_char_table(char *table)\n"
			  "{\n"
			  "\tmemcpy(table, local_table, sizeof(local_table));\n"
			  "}\n");
	}
	fclose(fp_out);
	return 0;
}
